function loadGameImage(_name) {
	var img = document.createElement('img');
	img.src = gameState.currentGame.gameName + '/img/' + _name + '.gif';
	img.style.position = 'absolute';
	img.style.display = 'none';
	
	gameState.currentGame.gameImages[_name] = img;
	document.getElementById('divGameArea').appendChild(img);
}

function destroyGameImage(_name) {
	var gameArea = document.getElementById('divGameArea');
	gameArea.removeChild(gameState.currentGame.gameImages[_name]);
	
	gameState.currentGame.gameImages[_name] = null;
}

function destroyCurrentGameImage() {
	//var gameArea = document.getElementById('divGameArea');
	document.getElementById('divGameArea').clear();
	//var imgs = gameState.currentGame.gameImages;
	//for (var i=0; i<imgs.length; i++) {
	//	imgs[i] = null;
	//}
	gameState.currentGame.gameImages = [];
}

function detectCollision(o1, o2) {
	var top1 = o1.y;
	var top2 = o2.y;
	var bottom1 = o1.height + top1;
	var bottom2 = o2.height + top2;
	
	if (bottom1 < top2) {
		return false;
	} else if (top1 > bottom2) {
		return false;
	}
	
	var left1 = o1.x;
	var left2 = o2.x;
	var right1 = o1.width + left1;
	var right2 = o2.width + left2;
	
	if (right1 < left2) {
		return false;
	} else if (left1 > right2) {
		return false;
	}
	
	return true;
}

function addToScore(s) {
	gameState.score += s;
}

function subtractFromScore(s) {
	var score = gameState.score;
	if (score < s) {
		gameState.score = 0;
	} else {
		gameState.score = score - s;
	}
}
